package com.hfut.jpoa.service.impl;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hfut.jpoa.common.dto.ResultDto;
import com.hfut.jpoa.common.util.DateUtils;
import com.hfut.jpoa.dao.NoticeDAO;
import com.hfut.jpoa.dto.NoticeDTO;
import com.hfut.jpoa.model.Customer;
import com.hfut.jpoa.model.Dispatch;
import com.hfut.jpoa.model.Notice;
import com.hfut.jpoa.service.NoticeService;
import com.hfut.jpoa.service.exception.DispatchException;
import com.hfut.jpoa.service.exception.NoticeException;

public class NoticeServiceImpl implements NoticeService
{
	private static final Logger LOGGER = LoggerFactory
	        .getLogger(NoticeServiceImpl.class);

	NoticeDAO noticeDAO;

	public ResultDto<Notice> queryInfoForPage(NoticeDTO condition)
	        throws NoticeException
	{
		ResultDto<Notice> findInfoForPage = noticeDAO
		        .findInfoForPage(condition);
		return findInfoForPage;
	}

	public void update(Notice record) throws NoticeException
	{
		noticeDAO.updateByPrimaryKeySelective(record);
	}

	public Notice findInfo(Notice condition) throws NoticeException
	{
		return noticeDAO.selectByPrimaryKey(condition.getNoticeId());
	}

	public boolean codeValidator(Notice condition) throws NoticeException
	{
		// TODO Auto-generated method stub
		return false;
	}

	public List<Notice> queryList(Notice condition) throws NoticeException
	{
		// TODO Auto-generated method stub
		return null;
	}

	public void saveNotice(Notice notice) throws NoticeException
	{
		if (null == notice)
		{
			LOGGER.error("notice is empty.");
			throw new NoticeException("notice info is empty");
		}
		notice.setResult("0");
		noticeDAO.insert(notice);

	}

	public NoticeDAO getNoticeDAO()
	{
		return noticeDAO;
	}

	public void setNoticeDAO(NoticeDAO noticeDAO)
	{
		this.noticeDAO = noticeDAO;
	}

}
